﻿package
{
	import flash.display.MovieClip;
	import flash.net.LocalConnection;
	
	public class CDocument extends MovieClip
	{
		private var conn:LocalConnection;
		
		public function CDocument()
		{
			conn = new LocalConnection();
			conn.allowDomain("*");
			conn.client = this;
			try
			{
				conn.connect("_loaderGameConnection");
			}
			catch (error:ArgumentError)
			{
				trace("Can't connect...the connection name is already being used by another SWF");
			}
//			var game :CGame = new CGame();
//			stage.addChild(game);
//			game.Init();
		}
		
		public function OnStartGameHandler():void
		{
			//trace("connect");
			ProcessStartGame();
			
			conn.close();
		}
		
		private function ProcessStartGame() :void
		{
			var game :CGame = new CGame();
			stage.addChild(game);
			game.Init();
		}
	}
}
